package com.yiyibook.entity;

import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * 会员信息 实体
 *
 * @author yi.wu
 * @date 2019-10-14
 */

@Data
public class Member {

    /**
     * 会员id
     */
    private Integer memberId;

    /**
     * 会员账号
     */
    @Pattern(regexp = "^[a-zA-Z0-9_]{4,16}$",
            message = "会员账号不能为空,且只能为4到16位（字母，数字，下划线）",
            groups = {Reg.class,Log.class,Upd.class})
    private String memberName;

    /**
     * 会员权限
     */
    private Integer memberRole;

    /**
     * 会员密码
     */
    @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,16}$",
            message = "会员密码不能为空,且最少8位,最多16位，至少1个大写字母，1个小写字母，1个数字",
            groups = {Reg.class,Log.class,Upd.class})
    private String memberPassword;

    /**
     * 会员真实姓名
     */
    @Size(min = 2,max = 6,
        message = "请输入真实姓名",
        groups = Upd.class)
    private String memberTrueName;

    /**
     * 会员电话号码
     */
    @Pattern(regexp = "^1[3456789]\\d{9}$",
            message = "手机号格式不正确",
            groups = {Reg.class,Upd.class})
    @NotBlank(message = "手机号不能为空")
    private String memberPhone;

    /**
     * 会员收货地址
     */
    private String memberAddress;

}